<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <script>
        const idcard = "12345612345612345X";
        const reg = /^[1-9]\d{16}[\dX]$/
        console.log(reg.test(idcard))
    </script>
</body>
</html>